home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / pm-utils / sleep.d / 98smart-kernel-video < prev    next >
Encoding:
Text File  |  2009-04-07  |  2.2 KB  |  88 lines

  1. #!/bin/sh
  2. #
  3. # Copyright 2008 Victor Lowther <victor.lowther@gmail.com>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of version 2 of the GNU General Public License as
  7. # published by the Free Software Foundation.
  8.  
  9.  
  10. . "${PM_FUNCTIONS}"
  11.  
  12.  
  13. # Test to see if the kernel has a video driver that is smart enough to 
  14. # handle quirks without external assistance. If it is, remove the quirks.
  15. smart_kernel_nvidia()
  16. {
  17.     # despite the bad rep the nvidia driver has, it is miles better than 
  18.     # any other video driver when it comes to handling power managment and
  19.     # suspend/resume in a quirk-free manner.
  20.     [ -d /sys/module/nvidia ] || return 1
  21.     remove_parameters --quirk-dpms-on \
  22.         --quirk-dpms-suspend \
  23.     --quirk-s3-mode \
  24.         --quirk-s3-bios \
  25.     --quirk-vbe-post \
  26.     --quirk-vbe-post \
  27.     --quirk-vga-mode3 \
  28.     --quirk-vbemode-restore \
  29.     --quirk-vbestate-restore \
  30.     --quirk-reset-brightness \
  31.     --quirk-radeon-off \
  32.     --quirk-no-fb \
  33.     --quirk-pci-save
  34. }
  35.  
  36. smart_kernel_fglrx()
  37. {
  38.     # the ATI driver is pretty good about it, too.
  39.     [ -d /sys/module/fglrx ] || return 1
  40.     remove_parameters --quirk-dpms-on \
  41.         --quirk-dpms-suspend \
  42.     --quirk-s3-mode \
  43.         --quirk-s3-bios \
  44.     --quirk-vbe-post \
  45.     --quirk-vbe-post \
  46.     --quirk-vga-mode3 \
  47.     --quirk-vbemode-restore \
  48.     --quirk-vbestate-restore \
  49.     --quirk-reset-brightness \
  50.     --quirk-radeon-off \
  51.     --quirk-no-fb \
  52.     --quirk-pci-save
  53. }
  54.  
  55. smart_kernel_intel()
  56. {
  57.     # currently, intel kernel modesetting is not quite smart enough
  58.     # we still need acpi s3 kernel modesetting hooks, so don't remove those
  59.     # options if they were passed.
  60.     [ -d /sys/module/i915 ] || return 1
  61.     
  62.     local kernel_rev="$(uname -r |awk -F '[_-]' '{print $1}')"
  63.     [ "$kernel_rev" \> "2.6.26" -o "$kernel_rev" = "2.6.26" ] || return 1
  64.     remove_parameters --quirk-dpms-on \
  65.         --quirk-dpms-suspend \
  66.     --quirk-vbe-post \
  67.     --quirk-vbe-post \
  68.     --quirk-vga-mode3 \
  69.     --quirk-vbemode-restore \
  70.     --quirk-vbestate-restore \
  71.     --quirk-reset-brightness \
  72.     --quirk-radeon-off \
  73.     --quirk-no-fb \
  74.     --quirk-pci-save
  75. }
  76.  
  77. smart_kernel_video() 
  78. {
  79.         smart_kernel_nvidia || smart_kernel_fglrx || smart_kernel_intel || \
  80.     return $NA
  81. }
  82.  
  83. case $1 in
  84.      suspend|hibernate)
  85.     smart_kernel_video ;;
  86.      *) exit 0 ;;
  87. esac
  88.